﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_Topmenu : System.Web.UI.UserControl
{
  protected void Page_Load(object sender, EventArgs e)
  {
    linkHome.CssClass = SetActiveLink("");
    linkSubscription.CssClass = SetActiveLink("Abonnement");
    linkStockAnalysis.CssClass = SetActiveLink("Aktieanalyser");
    linkStockguide.CssClass = SetActiveLink("Aktieguiden");
    linkKeyfigures.CssClass = SetActiveLink("Noegletal");
    linkAbout.CssClass = SetActiveLink("Analyseinvestor");
    linkAccount.CssClass = SetActiveLink("Konto");

    if (HttpContext.Current.User.Identity.IsAuthenticated)
    {
      linkAccount.Text = "Profil";
    }
  }

  private string SetActiveLink(string page)
  {
    string url = Request.RawUrl.ToString().ToLower();
    string[] s = url.Split('/'); //Splits URL at /
    return s[1].Equals(page.ToLower()) ? "current" : string.Empty;
  }
}